package com.ericsson.mna.model.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.ericsson.mna.model.pojo.DBConf;

public class OracleConnectionFactory {
	private static OracleConnectionFactory ocf;

	private OracleConnectionFactory() {
		super();
		
	}
	 public static OracleConnectionFactory getInstance(){
	        if(ocf == null){
	            ocf = new OracleConnectionFactory();
	        }
	        return ocf;
	    }

	 public Connection accessDB(DBConf dbConf) {
			

			Connection con=null;
			String driverName=dbConf.getDriverName();
			String url=dbConf.getUrl();
			String userName=dbConf.getUserName();
			String password=dbConf.getPassword();
			
			try {
				Class.forName(driverName);
				con=DriverManager.getConnection(url, userName, password);
			} catch (ClassNotFoundException e) {
				System.out.println("Exception caught in accessDB : "+e);
			} catch (SQLException sqe) {
				System.out.println("Exception caught in accessDB : "+sqe);
			}
			return con;
		}
}
